﻿#pragma once

#include "common.h"
#include <vector>

namespace anip
{
	class Texture2D;

	class PreloadedObject
	{
	public:
		PreloadedObject();
		PreloadedObject(const PreloadedObject&) = delete;

		virtual void load() = 0;
		virtual void finalize() = 0;
	};

	class PreloadedTexture : public PreloadedObject
	{
	private:
		string _path;
		Texture2D* _obj = nullptr;

	public:
		PreloadedTexture(const string& path) :
			PreloadedObject(), _path(path) {}
		PreloadedTexture(const PreloadedTexture&) = delete;

		void load() override;
		void finalize() override;
		Texture2D* get() const { return _obj; }

		
	};

	class Shared
	{
		friend class PreloadedObject;

	private:
		static std::vector<GLObject*> _objs;
		static std::vector<PreloadedObject*>* _preloads;
		static void addPreloadObject(PreloadedObject& obj);

	public:
		Shared() = delete;

		static int add(GLObject& s);
		static int add(std::initializer_list<GLObject*> objs);

		static void preloadObjects();

		static void finalize();
	};
}